<template>
	<view class="content">
		<view class="bgc_color">
			<view class="bgc_top"></view>
			<view class="bgc_bottom"></view>
		</view>
		<view class="container">
			<view class="top_container">
				<view class="top_item" @click="toPage('/pages/meter/meterManage')">
					<text class="iconfont icon-dianbiao"></text>
					<text>电表管理</text>
				</view>
				<view class="top_item" @click="toPage('/pages/meter/sendRecords')">
					<text class="iconfont icon-iconfontchangemeter-copy"></text>
					<text>抄表管理</text>
				</view>
				<view class="top_item" @click="toPage('/pages/eleOrder/eleOrderManage')">
					<text class="iconfont icon-dingdan1"></text>
					<text>电费订单</text>
				</view>
			</view>
			<view class="middle_container">
				<view class="middle_item">
					<text class="count">🕗</text>
					<text class="tip">电表总数</text>
				</view>
				<view class="middle_item">
					<text class="count">🕗</text>
					<text class="tip">抄表总数</text>
				</view>
				<view class="middle_item">
					<text class="count">🕗</text>
					<text class="tip">订单总数</text>
				</view>
			</view>
			<view class="bottom_container">
				<view class="bottom_title">
					建维管理
				</view>
				<view class="bottom_content">
					<view class="bottom_item" @click="toPage('/pages/meter/meterSend')">
						<text class="iconfont icon-dianfeijiaofei"></text>
						<text>电表抄表</text>
					</view>
					<view class="bottom_item" @click="toPage('/pages/meter/sendRecords')">
						<text class="iconfont icon-kaitongfuwu"></text>
						<text>抄表审核</text>
					</view>
					<view class="bottom_item" @click="toPage('/pages/meter/createEleOrder')">
						<text class="iconfont icon-dingdan"></text>
						<text>生成订单</text>
					</view>
					<!-- <view class="bottom_item" @click="toPage('/pages/eleOrder/eleOrderManage')">
						<text class="iconfont icon-hetongxuqianshenqing"></text>
						<text>查看订单</text>
					</view> -->
					<!-- <view class="bottom_item">
						<text class="iconfont icon-shenhe"></text>
						<text>发起审批</text>
					</view> -->
				</view>
			</view>
		</view>
		<u-tabbar :value="activeName" :placeholder="false" :border="false" @change="changePage">
			<u-tabbar-item name="home" text="首页" icon="home"></u-tabbar-item>
			<u-tabbar-item name="my" text="我的" icon="account"></u-tabbar-item>
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				activeName: 'home'
			}
		},
		onShow() {

		},
		methods: {
			changePage(val) {
				if (val === 'my') {
					uni.reLaunch({
						url: '/pages/mine/mine'
					})
				} else {
					uni.reLaunch({
						url: '/pages/index/index'
					})
				}
			},
			toPage(path) {
				const permissions = this.$store.state.user.permissions
				//电表管理、抄表审核 --电表权限
				if ((path === '/pages/meter/meterManage' || path === '/pages/meter/sendRecords') && !permissions.includes(
						'mini_meter')) {
					return uni.showToast({
						title: '无抄表权限，请联系管理员配置',
						type: 'error'
					})
				}
				//电表抄表、生成订单 --抄表权限
				if ((path === '/pages/meter/meterSend' || path === '/pages/meter/createEleOrder') && !permissions.includes(
						'mini_meter')) {
					return uni.showToast({
						title: '无抄表权限，请联系管理员配置',
						type: 'error'
					})
				}
				//电费订单 --订单权限
				if (path === '/pages/eleOrder/eleOrderManage' && !permissions.includes('mini_meter')) {
					return uni.showToast({
						title: '无抄表权限，请联系管理员配置',
						type: 'error'
					})
				}
				uni.navigateTo({
					url: path
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		.bgc_color {
			position: fixed;
			left: 0;
			right: 0;
			top: 0;
			bottom: 0;
			z-index: -1;

			.bgc_top {
				width: 100%;
				height: 35%;
				background-color: #5290FF;
			}

			.bgc_bottom {
				width: 100%;
				height: 65%;
				background-color: #F5F5F5;
			}
		}

		.top_container {
			position: fixed;
			left: 0;
			right: 0;
			top: 8%;
			display: flex;
			justify-content: center;
			align-items: center;

			.top_item {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				color: #fff;
				margin: 0 25rpx;
				padding: 30rpx;
				background-color: rgba(0, 0, 0, .1);
				border-radius: 20rpx;

				.iconfont {
					font-size: 60rpx;
					font-weight: 700;
					margin-bottom: 15rpx;
				}
			}
		}

		.middle_container {
			position: fixed;
			top: 25%;
			left: 3%;
			right: 3%;
			height: 20%;
			background-color: #fff;
			border-radius: 50rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.middle_item {
				flex: 1;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				font-size: 30rpx;
				color: #868e96;
				font-weight: 500;

				.tip {
					margin-top: 15rpx;
				}

				.count {
					font-size: 55rpx;
					font-weight: 700;
					color: #262626;
				}
			}
		}

		.bottom_container {
			position: fixed;
			left: 0;
			right: 0;
			bottom: 13%;
			height: 40%;
			background-color: #fff;

			.bottom_title {
				height: 15%;
				font-size: 35rpx;
				font-weight: 700;
				display: flex;
				align-items: center;
				padding: 0 30rpx;
				border-bottom: 1rpx solid #f8f9fa;
			}

			.bottom_content {
				height: 85%;
				display: flex;
				flex-wrap: wrap;

				.bottom_item {
					padding: 30rpx 10rpx;
					width: 33%;
					height: 50%;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					font-size: 32rpx;
					color: #495057;
					font-weight: 500;

					.iconfont {
						font-size: 60rpx;
						font-weight: 700;
						color: #868e96;
						align-items: center;
						margin-bottom: 30rpx;
					}

					&:nth-child(-n+3) {
						border-bottom: 1rpx solid #f1f3f5;
					}

					&:nth-child(3n-1) {
						border-left: 1rpx solid #f1f3f5;
						border-right: 1rpx solid #f1f3f5;
					}
				}
			}
		}
	}
</style>